#ifndef MDTX_USE_RCPPARMADILLO
#define MDTX_USE_RCPPARMADILLO
#endif

#include <RcppArmadillo.h>
using namespace Rcpp;

#include "mdtx-online/aggregator/aggregator_type_time.h"
using namespace mdtx::online;

#include "aggr_common.h"

using tumbling_ohlcv_itime_ = aggr<true,
                                   aggregator::tumbling_ohlcv<int, int, double>,
                                   IntegerVector,
                                   NumericVector>;

//' @rdname tumbling_ohlcv
//' @export
// [[Rcpp::export(rng = false)]]
List tumbling_ohlcv_itime(IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover,
                          int window_size, bool align_window = true)
{
    auto c = tumbling_ohlcv_itime_::create(window_size, 0, align_window);
    return tumbling_ohlcv_itime_::run_ohlcv7(c, time, price, volume, turnover);
}

// [[Rcpp::export(rng = false)]]
SEXP tumbling_ohlcv_itime_new(int window_size, bool align_window = true)
{
    return tumbling_ohlcv_itime_::create(window_size, 0, align_window);
}

// [[Rcpp::export(rng = false)]]
List tumbling_ohlcv_itime_run(SEXP ptr, IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover)
{
    return tumbling_ohlcv_itime_::run_ohlcv7(ptr, time, price, volume, turnover);
}

using tumbling_vwap_itime_ = aggr<true,
                                  aggregator::tumbling_vwap<int, int, double>,
                                  IntegerVector,
                                  NumericVector>;

//' @rdname tumbling_vwap
//' @export
// [[Rcpp::export(rng = false)]]
List tumbling_vwap_itime(IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover,
                         int window_size, bool align_window = true)
{
    auto c = tumbling_vwap_itime_::create(window_size, 0, align_window);
    return tumbling_vwap_itime_::run_ohlcv3(c, time, price, volume, turnover);
}

// [[Rcpp::export(rng = false)]]
SEXP tumbling_vwap_itime_new(int window_size, bool align_window = true)
{
    return tumbling_vwap_itime_::create(window_size, 0, align_window);
}

// [[Rcpp::export(rng = false)]]
List tumbling_vwap_itime_run(SEXP ptr, IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover)
{
    return tumbling_vwap_itime_::run_ohlcv3(ptr, time, price, volume, turnover);
}

using sliding_ohlcv_itime_ = aggr<true,
                                  aggregator::sliding_ohlcv<int, int, double>,
                                  IntegerVector,
                                  NumericVector>;

//' @rdname sliding_ohlcv
//' @export
// [[Rcpp::export(rng = false)]]
List sliding_ohlcv_itime(IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover,
                         int window_size)
{
    auto c = sliding_ohlcv_itime_::create(window_size);
    return sliding_ohlcv_itime_::run_ohlcv7(c, time, price, volume, turnover);
}

// [[Rcpp::export(rng = false)]]
SEXP sliding_ohlcv_itime_new(int window_size)
{
    return sliding_ohlcv_itime_::create(window_size);
}

// [[Rcpp::export(rng = false)]]
List sliding_ohlcv_itime_run(SEXP ptr, IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover)
{
    return sliding_ohlcv_itime_::run_ohlcv7(ptr, time, price, volume, turnover);
}

using sliding_vwap_itime_ = aggr<true,
                                 aggregator::sliding_vwap<int, int, double>,
                                 IntegerVector,
                                 NumericVector>;

//' @rdname sliding_vwap
//' @export
// [[Rcpp::export(rng = false)]]
List sliding_vwap_itime(IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover,
                        int window_size)
{
    auto c = sliding_vwap_itime_::create(window_size);
    return sliding_vwap_itime_::run_ohlcv3(c, time, price, volume, turnover);
}

// [[Rcpp::export(rng = false)]]
SEXP sliding_vwap_itime_new(int window_size)
{
    return sliding_vwap_itime_::create(window_size);
}

// [[Rcpp::export(rng = false)]]
List sliding_vwap_itime_run(SEXP ptr, IntegerVector time, NumericVector price, NumericVector volume, NumericVector turnover)
{
    return sliding_vwap_itime_::run_ohlcv3(ptr, time, price, volume, turnover);
}
